package com.tenbent.product.center.user.dto;

import com.tenbent.product.base.dto.BaseDto;
import com.tenbent.product.center.user.bo.User;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.NotNull;

/**
 * 用户DTO
 *
 * @author Randy
 *
 *         Created by ThinkPad on 2017/8/21.
 */
public class UserDto extends BaseDto {

	/** 登录ID */
	@NotNull(message = "{user.login.id.not.empty}")
	private String loginId;

	/** 密码 */
	@NotEmpty(message = "{user.password.not.empty}")
	private String password;

	/** 用户名称 */
	@NotEmpty(message = "{user.name.not.empty}")
	private String name;

	public UserDto() {

	}

	public UserDto(User user) {
		super(user);
		setLoginId(user.getLoginId());
		setPassword(user.getPassword());
		setName(user.getName());
	}

	public User transToBo() {
		User user = new User();
		super.transToBo(user);
		user.setLoginId(this.getLoginId());
		user.setPassword(this.getPassword());
		user.setName(this.getName());
		return user;
	}

	public String getLoginId() {
		return loginId;
	}

	public void setLoginId(String loginId) {
		this.loginId = loginId;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}
